<?php

!defined('IN_APP') && exit('Access Denied');

class usergroupmodel extends modelbase {
 
    function get($id) {
        return $this->collection->findOne (array("id" => $id));
    }

    function add($group) {
		$id=$this->get_autoincre_id('usergroup');
		$group['id'] = $id;
		$this->collection->insert($group); 
		return $id;
    }

    function update($id,$group) {
    	  $this->collection->update(array("id" => $id),array('$set' =>$group )); 
    }
    /**
     * 得到用户组信息
     *
     * @param int $grouptype
     * @param int $id 系统超级管理员id
     * @return array $grouplist
     */
    function get_list($grouptype=1) {
        $grouplist = array();
        $cursor = $this->collection->find(array("type"=>$grouptype))->sort(array('id' =>1));
        foreach($cursor as $group) {
            $grouplist[] = $group;
        }
        return $grouplist;
    }

    function remove($id) {
        return $this->collection->remove(array("id" => $id));
    }

}

